#include <stdio.h>
#include <stdlib.h>

int nomer_dnya (int D, int M, int Y)
{
	int nomerdnya=D;
	int i;
	int massiv[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

	if ( Y<=0 || (M > 12 || M < 1 ))
		return -1;


	if (   (Y%4 == 0 && Y%100 != 0) || (Y%400 == 0) )   
	{
		massiv[1] = 29;
	}
	
	if (D > massiv [M-1] || D<1)
		return -1;

	for (i=0; i< M-1; i++)
		nomerdnya += massiv[i];

	return nomerdnya;
}

int main ()
{
	int D, M, Y;
	printf("Vvedite den, mecyac i god cherez probel: \n");
	scanf("%d%d%d" , &D, &M, &Y);
	printf("Nomer_dnya v gody:  %d\n", nomer_dnya (D, M, Y));

	system("pause");
	return 0;
}